"""
    Redirect Test
"""
from django.http import HttpResponse, HttpResponseRedirect
from django.views.decorators.common import no_append_slash
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.gzip import gzip_page
from django.views.decorators.http import require_http_methods


@csrf_exempt
def redirect_link(request):
    """
    跳转到外链
    :param request:
    :return:
    """
    return HttpResponseRedirect('http://baidu.com/')


@csrf_exempt
@gzip_page  # 内容压缩
@require_http_methods(["GET", "POST"])  # 只允许 GET POST 请求
@no_append_slash
def view(request):
    return HttpResponse(" 内容压缩 只允许 GET POST 请求  ")


# 视图装饰器
@csrf_exempt
def redirect_view(request):
    """
    跳转到本模块视图
    :param request:
    :return:
    """
    return HttpResponseRedirect('view')


@csrf_exempt
def redirect_view1(request):
    """
    调整到其它模板视图
    :param request:
    :return:
    """
    return HttpResponseRedirect('/drf/view')
